package com.robot.orders.controller;

import com.alibaba.fastjson.JSON;
import com.robot.orders.pojo.OrdersDetails;
import com.robot.orders.service.OrdersDetailsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * details控制器层
 *
 * @author wuyunbin
 */
@RestController
@CrossOrigin
@RequestMapping("/details")
public class OrdersDetailsJsonController {

    @Autowired
    private OrdersDetailsService detailsService;

    /**
     * 传入ordersDetails来增加ordersDetails
     *
     * @param ordersDetails
     */
    @RequestMapping(value = "third/addOrdersDetailsByOrdersDetails", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
    public void thirdAddOrdersDetailsByOrdersDetails(@RequestBody String ordersDetails) {
        detailsService.add(JSON.parseObject(ordersDetails, OrdersDetails.class));
    }

    /**
     * 传入ordersDetails来修改ordersDetails
     *
     * @param ordersDetails
     */
    @RequestMapping(value = "third/updateOrdersDetailsByOrdersDetails", method = RequestMethod.PUT, produces = "application/json; charset=utf-8")
    public void thirdUpdateOrdersDetailsByOrdersDetails(@RequestBody String ordersDetails) {
        detailsService.update(JSON.parseObject(ordersDetails, OrdersDetails.class));
    }
}
